package Demo;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        Set<Integer> set = new HashSet<>();
        set.add(1);
        set.add(12);
        set.add(51);
        set.add(19);
        set.add(51);

        for (Integer i : set) {
            System.out.println(i);
        }
        System.out.println("---------------------------");
        //1.获取迭代对象
        Iterator<Integer> it = set.iterator();
        //2.迭代
        while (it.hasNext()){
            System.out.println(it.next());
        }
    }
}
